package app;

import cn.hsa.hsaf.idgenerator.IdGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by gulx@neusoft.com on 2020/3/25.
 */
@RestController
public class AppController {

    private static final Logger logger = LoggerFactory.getLogger(AppController.class);
    @Autowired
    IdGenerator idGenerator;

    @GetMapping(value = {"/"})
    public Long create() {
        long id = idGenerator.next("default");
        logger.info("default id:{}",id);
        return id;
    }

    @GetMapping(value = "/{name}")
    public Long create(@PathVariable String name) {
        long id = idGenerator.next(name);
        logger.info("key:{}, id:{}",name,id);
        return id;
    }
}
